﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;

namespace DISDisplay
{
    class Clock:Panel
    {
        public ClockDigit[] digit = new ClockDigit[6];
        Label dotlb1 = null;
        Label dotlb2 = null;

        public Clock()
        {
            digit[0] = new ClockDigit(30, 50);
            digit[0].simb = 4;
            digit[0].SetBounds(0, 5, 30, 50);
            digit[0].BringToFront();
            digit[0].parseSymbol('0');
           // digit[0].Start();

            digit[1] = new ClockDigit(30, 50);
            digit[1].simb = 4;
            digit[1].SetBounds(35, 5, 30, 50);
            digit[1].BringToFront();
            digit[1].parseSymbol('0');
            //digit[1].Start();

            digit[2] = new ClockDigit(30, 50);
            digit[2].simb = 4;
            digit[2].SetBounds(80, 5, 30, 50);
            digit[2].BringToFront();
            digit[2].parseSymbol('0');
            //digit[2].Start();

            digit[3] = new ClockDigit(30, 50);
            digit[3].simb = 4;
            digit[3].SetBounds(115, 5, 30, 50);
            digit[3].BringToFront();
            digit[3].parseSymbol('0');
            //digit[3].Start();

            digit[4] = new ClockDigit(30, 50);
            digit[4].simb = 4;
            digit[4].SetBounds(160, 5, 30, 50);
            digit[4].BringToFront();
            digit[4].parseSymbol('0');
            //digit[2].Start();

            digit[5] = new ClockDigit(30, 50);
            digit[5].simb = 4;
            digit[5].SetBounds(195, 5, 30, 50);
            digit[5].BringToFront();
            digit[5].parseSymbol('0');
            //digit[3].Start();

            dotlb1 = new Label();
            dotlb1.AutoSize = true;
            dotlb1.Name = "dots1";
            dotlb1.BringToFront();
            dotlb1.Text = ":";
            dotlb1.Font = new System.Drawing.Font("Microsoft Sans Serif", 40F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(186)));
            dotlb1.TabIndex = 0;
            dotlb1.SetBounds(53,-5,5,50);
            //dotlb1.Parent = this;
            

            dotlb2 = new Label();
            dotlb2.AutoSize = true;
            dotlb2.Name = "dots2";
            dotlb2.BringToFront();
            dotlb2.Text = ":";
            dotlb2.Font = new System.Drawing.Font("Microsoft Sans Serif", 40F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(186)));
            dotlb2.TabIndex = 0;
            dotlb2.SetBounds(133, -5, 5, 50);
            //dotlb2.Parent = this;

            this.Width = 225;
            this.Height = 60;
            this.BackColor = System.Drawing.Color.Transparent;
            this.BorderStyle = System.Windows.Forms.BorderStyle.None;

            this.Controls.Add(digit[0]);
            this.Controls.Add(digit[1]);
           this.Controls.Add(digit[2]);
            this.Controls.Add(digit[3]);
            this.Controls.Add(digit[4]);
            this.Controls.Add(digit[5]);
            this.Controls.Add(dotlb1);
            this.Controls.Add(dotlb2);
        }

        public void parseTime(String time)
        {
            string[] digits = time.Split(':');
            if (!this.digit[0].Symbol.Equals(digits[0][0]))
                this.digit[0].parseSymbol(digits[0][0]);
            if (!this.digit[1].Symbol.Equals(digits[0][1]))
                this.digit[1].parseSymbol(digits[0][1]);
            if (!this.digit[2].Symbol.Equals(digits[1][0]))
                this.digit[2].parseSymbol(digits[1][0]);
            if (!this.digit[3].Symbol.Equals(digits[1][1]))
                this.digit[3].parseSymbol(digits[1][1]);
            if (!this.digit[4].Symbol.Equals(digits[2][0]))
                this.digit[4].parseSymbol(digits[2][0]);
            if (!this.digit[5].Symbol.Equals(digits[2][1]))
                this.digit[5].parseSymbol(digits[2][1]);
        }

        public void setBackColor(Color cl)
        {
            this.digit[0].BackColor = cl;
            this.digit[1].BackColor = cl;
            this.digit[2].BackColor = cl;
            this.digit[3].BackColor = cl;
            this.digit[4].BackColor = cl;
            this.digit[5].BackColor = cl;
        }
    }
}
